
#ifndef __CC1101_H__
#define __CC1101_H__


#include "cc1101_reg.h"


#define PA_TABLE            {0xc2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,}    

enum
{
    CC1101_SPI_CSN_LEVEL_LOW,
    CC1101_SPI_CSN_LEVEL_HIGH,
};


typedef struct
{
    unsigned char   (*spi_transfer_byte)(unsigned char val);
    void            (*spi_csn_level)(unsigned char level);
    int             (*gdo0_input)(void);
    int             (*gdo2_input)(void);
    void            (*delay_ms)(unsigned int ms);
} cc1101_func_t;


/** ö?????? */
typedef enum 
{ 
  TX_MODE, 
  RX_MODE 
}CC1101_ModeType;

typedef enum 
{ 
  BROAD_ALL, 
  BROAD_NO, 
  BROAD_0, 
  BROAD_0AND255 
}CC1101_AddrModeType;

typedef enum 
{ 
  BROADCAST, 
  ADDRESS_CHECK
} CC1101_TxDataModeType;


void CC1101_Write_Cmd(unsigned char Command);
void CC1101_Write_Reg(unsigned char Addr, unsigned char WriteValue);
void CC1101_Write_Multi_Reg(unsigned char Addr, unsigned char *pWriteBuff, unsigned char WriteSize);
unsigned char CC1101_Read_Reg( unsigned char Addr );
void CC1101_Read_Multi_Reg( unsigned char Addr, unsigned char *pReadBuff, unsigned char ReadSize );
unsigned char CC1101_Read_Status( unsigned char Addr );
int CC1101_Set_Mode( CC1101_ModeType Mode );
void CC1101_Set_Idle_Mode( void );
void C1101_WOR_Init( void );
void CC1101_Set_Address( unsigned char address, CC1101_AddrModeType AddressMode);
void CC1101_Set_Sync( unsigned short Sync );
void CC1101_Clear_TxBuffer( void );
void CC1101_Clear_RxBuffer( void );
int CC1101_Tx_Packet( unsigned char *pTxBuff, unsigned char TxSize, CC1101_TxDataModeType DataMode );
unsigned char CC1101_Get_RxCounter( void );
char CC1101_Rx_Packet( unsigned char *RxBuff, int maxsize, int timeout);

void cc1101_register_spi_func(cc1101_func_t *func);
void CC1101_Init( void );
void cc1101_dump_register(void);
unsigned int cc1101_get_rssi(void);


#endif  /* __CC1101_H__ */
